package work.MrSun.xyq.controller;

/**
 * @Author MrSun
 * @Date 2023/5/2 14:19
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import work.MrSun.xyq.service.XyqMessageDetailService;
import work.MrSun.xyq.service.XyqUserService;
import work.MrSun.xyq.util.isUpdate.IsUpdate;

/**
 * 通过id进行更新用户的信息
 */
@RestController
public class UpdateMessageByUserIdController {
    @Autowired
    private XyqUserService xyqUserService;

    @Autowired
    private XyqMessageDetailService xyqMessageDetailService;

    /**
     *
     * @param id
     * @param messageId  信息的id
     * @param message  信息
     * @return
     */
    @Transactional
    @PostMapping("/updateMessageById/{id}/{messageId}")
    public IsUpdate updateMessageById(@PathVariable Integer id,
                                      @PathVariable Integer messageId,
                                      @RequestBody String message){
        return new IsUpdate().isTrue(id,messageId,message,xyqMessageDetailService,xyqUserService);
    }
}
